import unittest
from api.employee import EmployeeAPI
import json
from utils import common_assert

class TestEmployee(unittest.TestCase):
    # employee_id = None
    employee_id = "1475715545239236608"
    def setUp(self):
        print("开始")
        self.employee_api = EmployeeAPI()
        print("结束")


    def test01_add_employee(self):
        add_employee_data = {
            "username": "jh847766",  # 用户名唯一
            "mobile": "13215982666",  # 手机号唯一
            "timeOfEntry": "2020-07-09",
            "formOfEmployment": 1,
            "workNumber": "037213091616",  # 员工ID唯一性
            "departmentName": "销售",
            "departmentId": "1266699057968001024",
            "correctionTime": "2020-07-30T16:00:00.000Z"
        }
        reponse = self.employee_api.add_employee(add_employee_data=add_employee_data)
        # self.assertEqual(200,reponse.status_code)
        # print("出结果了")
        # print(reponse.json())
        # self.assertEqual(True,reponse.json().get("success"))
        # self.assertEqual(10000,reponse.json().get("code"))
        # self.assertIn("操作成功",reponse.json().get("message"))
        common_assert(self,reponse)
        TestEmployee.employee_id = reponse.json().get("data").get("id")
        print(TestEmployee.employee_id)
    def test02_update_employee(self):
        update_employee_data = {
            "username": "rose9090",  # 用户名唯一
        }
        reponse = self.employee_api.update_employee(TestEmployee.employee_id,update_employee_data)
        common_assert(self, reponse)

    def test03_get_employee(self):

        reponse = self.employee_api.get_employee(TestEmployee.employee_id)
        common_assert(self, reponse)

    def test04_delete_employee(self):

        reponse = self.employee_api.delete_employee(TestEmployee.employee_id)
        common_assert(self, reponse)



